package com.dcivision.framework.taglib.channel;

import javax.servlet.jsp.PageContext;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.SystemFunctionConstant;
import com.dcivision.framework.TextUtility;
import com.dcivision.workflow.taglib.WorkflowStepInfoTag;

public class AjaxWorkflowStepInfoTag extends WorkflowStepInfoTag {

  /**
   * before use this method ,please init the parameters,see super class WorkflowStepInfoTag
   * @return
   * @throws ApplicationException
   */
  public String getAjaxContent() throws ApplicationException{
    this.init();
    return this.getContent();
  }
  public PageContext getPageContext() {
    return pageContext;
  }
  protected String getContent() throws ApplicationException {
    StringBuffer sb = new StringBuffer();
    this.setRight("R");
    this.setObjectType(GlobalConstant.WORKFLOW_OWNER_PERMISSION);
    this.setObjectID(this.getWorkflowProgress().getWorkflowStepID());
    if (this.checkPermission()) {
      sb.append ("<a ");
      sb.append ( "  style=\"text-decoration: none; cursor:text; \"   " );
      if (getFunctionCode().equals(SystemFunctionConstant.WORKFLOW_TASK)) {
        sb.append("onmouseover=\"return getPopupInfo('");
        sb.append(TextUtility.escapeJSString(getActorNameDescription()));
        sb.append(TextUtility.escapeJSString(getFilterByDescription()));
        sb.append("');\" ");
        sb.append("onmouseout=\"return nd();\"");
      }
      sb.append (">");
      sb.append ( this.getWorkflowProgress().getStepName() );
      sb.append ( "</a>" );
    }else{
      sb.append ( this.getWorkflowProgress().getStepName() );
    }

    return sb.toString();
  }
  public void setPageContext(PageContext pageContext) {
    this.pageContext = pageContext;
  }

}
